package de.zainodis.triplog.ui.task;

import android.content.Context;
import android.content.CursorLoader;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;

import de.zainodis.triplog.data.TripEntry;
import de.zainodis.triplog.data.persistence.ITripDao;
import de.zainodis.triplog.data.persistence.IWeatherDao;
import de.zainodis.triplog.data.share.TriplogContract;
import de.zainodis.triplog.data.share.WeatherProvider;
import de.zainodis.triplog.util.DateTimeUtils;
import de.zainodis.triplog.util.Utilities;

/**
 * Created by fzarrai on 1/25/2015.
 * Loads all completed trips. Displays the following information: One screenshot on the left, the destination on the upper right and the date below that.
 */
public class CompletedTripsLoader extends CursorLoader {

    public static final String[] COLUMNS = {
            ITripDao.TABLE_NAME + "." + ITripDao.COLUMN_ID,
            ITripDao.COLUMN_DATE_START,
            ITripDao.COLUMN_DATE_END
    };

    public static final int COLUMN_ID = 0;
    public static final int COLUMN_DATE_START = 1;
    public static final int COLUMN_DATE_END = 2;

    public CompletedTripsLoader(Context context) {
        super(context);
    }

    @Override
    public Cursor loadInBackground() {

        //Returns a cursor harboring all completed trips, the rest can be retrieved later
        Cursor cursor = getContext().getContentResolver().query(
                TriplogContract.CONTENT_URI_TRIP, null, WeatherProvider.TRIPS_BY_END_DATE_SELECTION,
                new String[]{TripEntry.STRING_DEFAULT_VALUE},
                null);

        return cursor;
    }
}
